/*
*Copyright (c) Nikhil Jain.
*Project ICARUS, communications and 
*artificial intelligence.
*/



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */
package javadrone;

//~--- JDK imports ------------------------------------------------------------

import java.io.*;

import java.util.Calendar;

/**
 *
 * @author Nikzzay
 */
public class RemoteImage implements Serializable {
    public final long TIMESTAMP;
    private byte[]    bytes;

    public RemoteImage(byte[] bytes, long TIMESTAMP) {
        this.bytes     = bytes;
        this.TIMESTAMP = TIMESTAMP;
    }

    public void write(ByteArrayOutputStream bos) throws IOException {
        bos.write(bytes);
        bos.close();
    }

    public byte[] getBytes() {
        return bytes;
    }

    public void writeToFile() throws IOException {
        System.out.println("Currently working to write image...");

        File file = new File("/img" + Calendar.getInstance().getTimeInMillis() + ".jpg");

        System.out.println(file);

        FileOutputStream fos = new FileOutputStream(file);

        fos.write(bytes);
    }

    public long getTimestamp() {
        return TIMESTAMP;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
